package com.ruoyi.web.controller.record;

import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.record.domain.BacklogRecord;
import com.ruoyi.record.domain.query.BacklogRecordQuery;
import com.ruoyi.record.domain.vo.BacklogRecordVo;
import com.ruoyi.record.service.IBacklogRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 * @author lisongtao
 * @date 2023/10/24 23:42
 */
@RestController
@RequestMapping("/backlog")
public class BacklogRecordController extends BaseController {


    @Autowired
    private IBacklogRecordService backlogRecordService;

    /**
     * 查询代办/已办记录
     */
    @PostMapping("/selectBacklogRecords")
    public TableDataInfo selectBacklogRecords(@RequestBody BacklogRecordQuery backlogRecordQuery) {
        List<BacklogRecord> backlogRecords = backlogRecordService.selectBacklogRecords(backlogRecordQuery);
        Long countNum = backlogRecordService.countBacklogRecords(backlogRecordQuery);
        TableDataInfo dataTable = new TableDataInfo();
        dataTable.setCode(HttpStatus.SUCCESS);
        dataTable.setRows(backlogRecords);
        dataTable.setTotal(countNum);
        return dataTable;
    }


    /**
     * 查询代办记录详情
     */
    @PostMapping("/selectBacklogRecordById")
    public AjaxResult selectBacklogRecordById(@RequestBody BacklogRecordQuery recordQuery) {
        return AjaxResult.success(backlogRecordService.selectBacklogRecordById(recordQuery));
    }

    /**
     * 处理待办记录
     */
    @PostMapping("/processBacklog")
    public AjaxResult processBacklog(@RequestBody BacklogRecordVo backlogRecordVo) {
        backlogRecordService.processBacklog(backlogRecordVo);
        return AjaxResult.success();
    }

}
